#include <bits/stdc++.h>
using namespace std;
using uint=unsigned int;
using ll=long long;
using ull=unsigned long long;
using i128=__int128;
const int N=1e6+5;

void solve(){
    int n,b;
    cin>>n>>b;
    int sum=0,pos=0,ans=1;
    map<int,int> mp;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]>b)a[i]=1;
        else if(a[i]<b)a[i]=-1;
        else pos=i;
    }
    for(int i=pos-1;i>=0;i--){
        sum+=a[i];
        if(sum==0)ans++;
        mp[sum]++;
    }
    sum=0;
    for(int i=pos+1;i<n;i++){
        sum+=a[i];
        if(sum==0)ans++;
        ans+=mp[-sum];
    }
    cout<<ans<<endl;
    return;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();

    return 0;
}